package controller.admin.employee;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import model.entity.Employee;
import service.Impl.EmployeeServiceImpl;
import util.GetJsonUtil;
import util.ResultUtil;

import java.io.IOException;
@WebServlet("/admin/employee/get")
public class EmployeeByIdController extends HttpServlet {
    //根据id查询员工
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id=req.getParameter("id");
        int ID= Integer.parseInt(id);
        EmployeeServiceImpl service=new EmployeeServiceImpl();

        Employee employee=service.Find(ID);

        System.out.println("id查询信息："+employee.getName());
        String json= ResultUtil.getJSON(employee);
        //发送到前端
        resp.getWriter().write(json);
    }
}
